// import { createRouter, createWebHistory } from "vue-router";
import { createRouter, createWebHashHistory } from 'vue-router';
import HomePage from "../views/home/HomePage.vue";
import AuthRoutes from "./auth.routes";
import CoursePerformance from "../views/performance/CoursePerformance.vue";
import Movie from "../views/performance/Movie.vue";
import VideoCourse from "../views/course/VideoCourse.vue";
import VideoDetail from "../views/course/VideoDetail.vue";
import VideoClass from "../views/course/VideoClass.vue";
import AboutWenChuan from "../views/wenchuan/AboutWenChuan.vue";
import lingnanCulture from "../views/lingnan/lingnanCulture.vue";
import finalUI from "../views/studentwork/finalUI.vue";
import completionVideo from "../views/studentwork/completionVideo.vue";
import miniProgram from "../views/studentwork/miniProgram.vue";
import completionSite from "../views/studentwork/completionSite.vue";
import NotFound from "../views/NotFound.vue";

const routes = [
  {
    path: "/",
    name: "home",
    component: HomePage,
    meta: {
      title: "首页",
      layout: "main",
    },
  },
  {
    path: "/VideoCourse",
    name: "course",
    component: VideoCourse,
    meta: {
      title: "视频课程",
      layout: "main",
    },
  },
  {
    path: "/AboutWenChuan",
    name: "aboutWenC",
    component: AboutWenChuan,
    meta: {
      title: "关于文传",
      layout: "default",
    },
  },
  {
    path: "/CoursePerformance",
    name: "performance",
    component: CoursePerformance,
    meta: {
      title: "课程展演",
      layout: "main",
    },
  },
  {
    path: "/VideoDetail",
    name: "videoDetail",
    component: VideoDetail,
    meta: {
      title: "课程视频详情",
      layout: "default",
    },
  },
  {
    path: "/VideoClass",
    name: "VideoClass",
    component: VideoClass,
    meta: {
      title: "课程视频分类",
      layout: "default",
    },
  },
  {
    path: "/Movie",
    name: "Movie",
    component: Movie,
    meta: {
      title: "实践展演视频",
      layout: "default",
    },
  },
  {
    path: "/lingnanCulture",
    name: "lingnanCulture",
    component: lingnanCulture,
    meta: {
      title: "岭南文化",
      layout: "default",
    },
  },
  {
    path: "/finalUI",
    name: "finalUI",
    component: finalUI,
    meta: {
      title: "毕设UI作品",
      layout: "default",
    },
  },
  {
    path: "/completionVideo",
    name: "completionVideo",
    component: completionVideo,
    meta: {
      title: "毕设影视作品",
      layout: "default",
    },
  },
  {
    path: "/miniProgram",
    name: "miniProgram",
    component: miniProgram,
    meta: {
      title: "毕设小程序作品",
      layout: "default",
    },
  },
  {
    path: "/completionSite",
    name: "completionSite",
    component: completionSite,
    meta: {
      title: "毕设网站",
      layout: "default",
    },
  },

  ...AuthRoutes,
  {
    path: "/:catchAll(.*)",
    component: NotFound,
    meta: {
      layout: "default",
    },
  },
];

const router = createRouter({
  // history: createWebHistory(import.meta.env.VITE_BASE_URL), // 使用 VITE_ 前缀的环境变量
  history: createWebHashHistory(),  // 使用 Hash 模式
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
